-
Notifications
You must be signed in to change notification settings - Fork 0
/
e-commerce use case for qworum.ts
76 lines (67 loc) · 1.99 KB
/
e-commerce use case for qworum.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Placeholder for the Json datatype.
* @see {@link https://qworum.net/en/specification/v1/#json}
*/
type JsonValue = string | number | boolean | Array<JsonValue> | {} | null;
/**
* Interface for a shopping cart service.
*/
interface IShoppingCart {
/**
* All articles in the shopping cart.
* The name of the Qworum data container is 'line items'.
* @public
*/
lineItems: JsonValue;
/**
* Total in EUR of all articles in the shopping cart.
* The name of the Qworum data container is 'total'.
* @public
*/
total: JsonValue;
/**
* Interactive endpoint that adds items to the shopping cart.
* Absolute path within the service's web origin: /add-items/
* @public
* @param {JsonValue} lineItemsToAdd - The name of the Qworum call parameter is 'line items to add'.
* @returns {JsonValue}
*/
addItems: (lineItemsToAdd: JsonValue) => JsonValue;
/**
* Interactive endpoint that shows the cart contents to the end-user,
* who can then check out.
* Absolute path within the service's web origin: /show-cart/
* @public
* @returns {JsonValue}
*/
showCart: () => JsonValue;
}
/**
* Interface for an e-shop service.
* The endpoint that acts as an application is `home`.
*/
interface IShop {
/**
* Remote shopping cart service.
* The name of the Qworum object is 'shopping cart'.
* @private
*/
shoppingCart: IShoppingCart;
/**
* Main interactive endpoint. Never returns.
* Absolute path within web origin: /home/
* @public
* @returns {JsonValue}
*/
home: () => JsonValue;
/**
* Interactive endpoint that shows an article to the end-user,
* who can then add the article to the shopping cart.
* This endpoint is called internally by the `home` endpoint.
* Absolute path within web origin: /view-article/
* @private
* @param {JsonValue} articleId - A string. The name of the Qworum call parameter is 'article id'.
* @returns {JsonValue}
*/
viewArticle(articleId: JsonValue): JsonValue;
}